M64NAM=mupen64plus-core
M64_BRANCH=${BRANCH:-master}
M64_URL="https://github.com/mupen64plus/$M64NAM.git"

PKG="$HOME"/games/emu/mupen64plus
M64=${M64:-"$GITSRC"}/mupen64plus/$M64NAM
M64_TMP="$TMP"../$M64NAM
SRC="$GITSRC"/mupen64plus/$PRGNAM
TMP="$TMP"/mupen64plus/$PRGNAM

_m64make () {
  _makefile="$1"
  shift
  _make '' "$SRC/$_makefile" \
    "${@:-}" \
    CC="${CC:-cc}" \
    CXX="${CXX:-c++}" \
    DEBUG="$DEBUG" \
    PREFIX="$PKG" \
    APIDIR="$M64"/src/api \
    DESTDIR="$DST"
  unset _makefile
}

if [ "$PRGNAM" = GLideN64 ] || [ "$PRGNAM" = angrylion-rdp-plus ]; then
  _flags cmake
else
  [ "$PRGNAM" = "$M64NAM" ] ||
    _git "$M64" "$M64NAM" "$M64_URL" "$M64_TMP" "$M64_BRANCH" "${M64_COMMIT:-}"
  _flags
fi

_git "$SRC" "$PRGNAM" "$URL" "$TMP" "$BRANCH" "${COMMIT:-}"
